<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <base href="${pageContext.request.contextPath}/"/>
    <title>修改分类</title>
    <meta charset="utf-8"/>
    <link rel="stylesheet" href="css/admin.css"/>
    <style>
        .error { color: red; font-size: 12px; }
        label.error { display: block; margin-top: 5px; }
    </style>
</head>
<body>
<div class="container">
    <div id="header">
        <div class="logo">
            <a href=""><img src="images/admin/logo.png" width="303" height="43"/></a>
        </div>
        <p>
            <a href="/admin/logout">退出管理</a>
            <a href="/admin">后台首页</a>
            <a href="/" target='_blank'>商城首页</a>
            <span>您好 <label class='bold'>${sessionScope.loginUser.account}</label></span>
        </p>
    </div>

    <div id="admin_left">
        <ul class="submenu">
            <ul class="menu">
                <li><a href="${pageContext.request.contextPath}/admin/category/add">增加类别</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/category/list">类别列表</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/goods/add">增加商品</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/goods/list">商品列表</a></li>
                <li><a href="${pageContext.request.contextPath}/admin/user/list">用户列表</a></li>
            </ul>
        </ul>
        <div id="copyright"></div>
    </div>

    <div id="admin_right">
        <div class="content_box">
            <div class="content form_content">
                <form action="${pageContext.request.contextPath}/admin/category/edit" method="post">
                    <table class="form_table" cellpadding="0" cellspacing="0">
                        <col width="150px"/>
                        <col/>
                        <tr>
                            <th>分类名称：</th>
                            <td>
                                <input class="normal" name="name" type="text"
                                       value="${category.name}" required maxlength="20">
                                <label class="error">${errors.name}</label>
                            </td>
                        </tr>
                        <tr>
                            <th>父分类：</th>
                            <td>
                                <select class="normal" name="pid">
                                    <option value="0">-- 无父分类 --</option>
                                    <c:forEach items="${categories}" var="cat">
                                        <c:if test="${cat.id != category.id}">
                                            <option value="${cat.id}"
                                                ${category.pid == cat.id ? 'selected' : ''}>
                                                    ${cat.name}
                                            </option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                                <label class="error">${errors.pid}</label>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <input type="hidden" name="id" value="${category.id}">
                                <button class="submit" type="submit">
                                    <span>保存</span>
                                </button>
                                <a href="${pageContext.request.contextPath}/admin/category/list"
                                   class="btn-cancel">取消</a>
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>
    <div id="separator"></div>
</div>
</body>
</html>